<%-- 
    Document   : messages
    Created on : Mar 4, 2014, 10:36:09 PM
    Author     : Jordan
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>

<c:set scope="request" var="title" value="Contracts"/>

<sql:setDataSource user="root" password="" driver="com.mysql.jdbc.Driver"
                   url="jdbc:mysql://localhost/bonix"/>

               <%
                Cookie cookie = null;
                Cookie[] cookies = null;
                // Get an array of Cookies associated with this domain
                cookies = request.getCookies();
                if( cookies != null ){
                   for (int i = 0; i < cookies.length; i++){
                        cookie = cookies[i];
                        if(cookie.getName().equals("username")){
                            %>
<sql:query var="getContracts">
    select trans_id,servp,cust,date,description from contracts where cust = "<%out.print(""+cookie.getValue()+"");%>"
</sql:query>
                <%
                        }
                   }
                }
                %>

<!DOCTYPE html>
<html>
    <jsp:include page="head.jsp"/>

    <body>
        <jsp:include page="header.jsp"/>

        <div class="row">
            <div class="container">
                <div class="content row">

                    <div class="containerService">

                        <div class="panel panel-primary">
                            <div class="panel-heading">
                                <h3 class="panel-title">SERVICE PROVIDER</h3>
                            </div>

                            <div class="panel-body">
                                <table class="table table-hover table-condensed">
                                    <thead>  
                                        <tr>  
                                            <th>SERVICE PROVIDER</th>
                                            <th>DESCRIPTION </th>
                                            <th>DATE</th>  
                                            <th>STATUS</th>   
                                        </tr>  
                                    </thead> 
                                    <tbody>
                                        <c:forEach var="contracts" items="${getContracts.rows}">                                          
                                            <tr>                                       
                                                <td class="text-left"><a href="checkContract.jsp?servp='${contracts.servp}"/>${contracts.servp}</td>
                                                <td class="text-left">${contracts.description}</td>
                                                <td class="text-left">${contracts.date}</td>
                                                <td class="text-left">${contracts.status}</td>
                                            </tr>  
                                        </c:forEach>
                                    </tbody>
                                </table>
                            </div>
                        </div><!-- END panel-body -->

                    </div><!-- END containerService -->

                </div><!-- END CONTENT CONTENT ROW -->
            </div><!-- END CONTAINER -->
        </div><!-- END ROW -->

        <jsp:include page="footer.jsp"/>

    </body>
</html>
